import 'package:json_annotation/json_annotation.dart';

part 'weather.g.dart';

@JsonSerializable()
class Weather {
  @JsonKey(name: "weather")
  final List<WeatherElement> weather;
  @JsonKey(name: "main")
  final Main main;
  @JsonKey(name: "dt")
  final int dt;

  Weather({
    required this.weather,
    required this.main,
    required this.dt,
  });

  factory Weather.fromJson(Map<String, dynamic> json) =>
      _$WeatherFromJson(json);

  Map<String, dynamic> toJson() => _$WeatherToJson(this);
}

@JsonSerializable()
class Main {
  @JsonKey(name: "temp")
  final double temp;
  @JsonKey(name: "temp_min")
  final double tempMin;
  @JsonKey(name: "temp_max")
  final double tempMax;

  Main({
    required this.temp,
    required this.tempMin,
    required this.tempMax,
  });

  factory Main.fromJson(Map<String, dynamic> json) => _$MainFromJson(json);

  Map<String, dynamic> toJson() => _$MainToJson(this);
}

@JsonSerializable()
class WeatherElement {
  @JsonKey(name: "main")
  final String main;
  @JsonKey(name: "description")
  final String description;
  @JsonKey(name: "icon")
  final String icon;

  WeatherElement({
    required this.main,
    required this.description,
    required this.icon,
  });

  factory WeatherElement.fromJson(Map<String, dynamic> json) =>
      _$WeatherElementFromJson(json);

  Map<String, dynamic> toJson() => _$WeatherElementToJson(this);
}
